package com.guchenbo.example.dubbo.cluster;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.LoadBalance;

public class GcbLoadBalance implements LoadBalance {

  private AtomicInteger cnt = new AtomicInteger();

  @Override
  public <T> Invoker<T> select(List<Invoker<T>> invokers, URL url, Invocation invocation)
      throws RpcException {
    return invokers.get(cnt.getAndIncrement() % invokers.size());
  }
}
